package com.xxx.video.commen.views;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import butterknife.ButterKnife;

public abstract class BaseToast extends Toast {
    public Context context;

    public BaseToast(Context context) {
        super(context);
        this.context = context;
        this.setGravity(17, 0, 0);
        if (context != null) {
            View view = LayoutInflater.from(context).inflate(getContentLayout(), (ViewGroup) null);
            this.setView(view);
            ButterKnife.bind(this, view);
            this.initView(view);
            this.initListener();
            this.initData();
        }
    }

    /**
     * init data
     */
    protected abstract void initData();

    /**
     * init listener
     */
    protected abstract void initListener();

    /**
     * init view
     *
     * @param view root view
     */
    protected abstract void initView(View view);

    /**
     * get content layout
     *
     * @return layout id
     */
    protected abstract int getContentLayout();
}
